static void
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint32 time,
gpointer data)
#include "gdkpipeiostreamprivate.h"
#include "gdktexture.h"
+#include <gobject/gvaluecollector.h>
+
/**
* SECTION:gdkclipboard
* @Short_description: Share data between applications for Copy-and-Paste
}
/**
- * gdk_clipboard_set_text:
+ * gdk_clipboard_set:
* @clipboard: a #GdkClipboard
- * @text: Text to put into the clipboard
+ * @type: type of value to set
+ * @...: value contents conforming to @type
*
- * Puts the given @text into the clipboard.
+ * Sets the clipboard to contain the value collected from the given
+ * varargs.
**/
void
-gdk_clipboard_set_text (GdkClipboard *clipboard,
- const char *text)
+gdk_clipboard_set (GdkClipboard *clipboard,
+ GType type,
+ ...)
+{
+ va_list args;
+
+ g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+ va_start (args, type);
+ gdk_clipboard_set_valist (clipboard, type, args);
+ va_end (args);
+}
+
+/**
+ * gdk_clipboard_set_valist: (skip)
+ * @clipboard: a #GdkClipboard
+ * @type: type of value to set
+ * @args: varargs containing the value of @type
+ *
+ * Sets the clipboard to contain the value collected from the given
+ * @args.
+ **/
+void
+gdk_clipboard_set_valist (GdkClipboard *clipboard,
+ GType type,
+ va_list args)
{
- GdkContentProvider *provider;
GValue value = G_VALUE_INIT;
+ char *error;
g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, text);
- provider = gdk_content_provider_new_for_value (&value);
+ G_VALUE_COLLECT_INIT (&value, type,
+ args, G_VALUE_NOCOPY_CONTENTS,
+ &error);
+ if (error)
+ {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ /* we purposely leak the value here, it might not be
+ * in a sane state if an error condition occoured
+ */
+ return;
+ }
+
+ gdk_clipboard_set_value (clipboard, &value);
g_value_unset (&value);
+}
+
+/**
+ * gdk_clipboard_set_value: (rename-to gdk_clipboard_set)
+ * @clipboard: a #GdkClipboard
+ * @value: a #GValue to set
+ *
+ * Sets the @clipboard to contain the given @value.
+ **/
+void
+gdk_clipboard_set_value (GdkClipboard *clipboard,
+ const GValue *value)
+{
+ GdkContentProvider *provider;
+
+ g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+ g_return_if_fail (G_IS_VALUE (value));
+
+ provider = gdk_content_provider_new_for_value (value);
gdk_clipboard_set_content (clipboard, provider);
g_object_unref (provider);
}
/**
- * gdk_clipboard_set_texture:
+ * gdk_clipboard_set_text: (skip)
+ * @clipboard: a #GdkClipboard
+ * @text: Text to put into the clipboard
+ *
+ * Puts the given @text into the clipboard.
+ **/
+void
+gdk_clipboard_set_text (GdkClipboard *clipboard,
+ const char *text)
+{
+ g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+ gdk_clipboard_set (clipboard, G_TYPE_STRING, text);
+}
+
+/**
+ * gdk_clipboard_set_texture: (skip)
* @clipboard: a #GdkClipboard
* @texture: a #GdkTexture to put into the clipboard
*
gdk_clipboard_set_texture (GdkClipboard *clipboard,
GdkTexture *texture)
{
- GdkContentProvider *provider;
- GValue value = G_VALUE_INIT;
-
g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
g_return_if_fail (GDK_IS_TEXTURE (texture));
- g_value_init (&value, GDK_TYPE_TEXTURE);
- g_value_set_object (&value, texture);
- provider = gdk_content_provider_new_for_value (&value);
- g_value_unset (&value);
-
- gdk_clipboard_set_content (clipboard, provider);
- g_object_unref (provider);
+ gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, texture);
}
gboolean gdk_clipboard_set_content (GdkClipboard *clipboard,
GdkContentProvider *provider);
GDK_AVAILABLE_IN_3_94
+void gdk_clipboard_set (GdkClipboard *clipboard,
+ GType type,
+ ...);
+GDK_AVAILABLE_IN_3_94
+void gdk_clipboard_set_valist (GdkClipboard *clipboard,
+ GType type,
+ va_list args);
+GDK_AVAILABLE_IN_3_94
+void gdk_clipboard_set_value (GdkClipboard *clipboard,
+ const GValue *value);
+GDK_AVAILABLE_IN_3_94
void gdk_clipboard_set_text (GdkClipboard *clipboard,
const char *text);
GDK_AVAILABLE_IN_3_94
guint time);
static void gtk_calendar_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time);
static gboolean gtk_calendar_drag_motion (GtkWidget *widget,
static void
gtk_calendar_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
static void
swatch_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
{
GtkWidget *widget; /* Widget in which drag is in */
GdkDragContext *context; /* Drag context */
- gint drop_x, drop_y; /* Position of drop */
};
#define DROP_ABORT_TIME 300000
gpointer data)
{
GdkDragContext *context;
- GtkDragDestInfo *info;
GtkWidget *drop_widget;
GdkAtom target;
drop_widget = data;
context = g_object_get_data (G_OBJECT (widget), "drag-context");
- info = gtk_drag_get_dest_info (context, FALSE);
target = gtk_selection_data_get_target (selection_data);
if (target == gdk_atom_intern_static_string ("DELETE"))
gtk_selection_data_get_length (selection_data) >= 0)
g_signal_emit_by_name (drop_widget,
"drag-data-received",
- context, info->drop_x, info->drop_y,
+ context,
selection_data,
time);
}
{
g_signal_emit_by_name (drop_widget,
"drag-data-received",
- context, info->drop_x, info->drop_y,
+ context,
selection_data,
time);
}
info = gtk_drag_get_dest_info (context, FALSE);
g_return_val_if_fail (info != NULL, FALSE);
- info->drop_x = x;
- info->drop_y = y;
-
if (site->flags & GTK_DEST_DEFAULT_DROP)
{
GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
gint dnd_position; /* In chars, -1 == no DND cursor */
gint drag_start_x;
gint drag_start_y;
+ gint drop_position; /* where the drop should happen */
gint insert_pos;
gint selection_bound;
gint scroll_offset;
guint time);
static void gtk_entry_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time);
static void gtk_entry_drag_data_get (GtkWidget *widget,
target = gtk_drag_dest_find_target (widget, context, NULL);
if (target != NULL)
- gtk_drag_get_data (widget, context, target, time);
+ {
+ priv->drop_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
+ gtk_drag_get_data (widget, context, target, time);
+ }
else
gtk_drag_finish (context, FALSE, FALSE, time);
static void
gtk_entry_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
if (str && priv->editable)
{
- gint new_position;
gint sel1, sel2;
gint length = -1;
if (priv->truncate_multiline)
length = truncate_multiline (str);
- new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
-
if (!gtk_editable_get_selection_bounds (editable, &sel1, &sel2) ||
- new_position < sel1 || new_position > sel2)
+ priv->drop_position < sel1 || priv->drop_position > sel2)
{
- gtk_editable_insert_text (editable, str, length, &new_position);
+ gtk_editable_insert_text (editable, str, length, &priv->drop_position);
}
else
{
static void gtk_file_chooser_button_destroy (GtkWidget *widget);
static void gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *data,
guint drag_time);
static void gtk_file_chooser_button_show (GtkWidget *widget);
static void
gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *data,
guint drag_time)
{
if (GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->drag_data_received != NULL)
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->drag_data_received (widget,
context,
- x, y,
data,
drag_time);
static void
file_list_drag_data_received_cb (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time_,
gpointer user_data)
guint time);
static void gtk_icon_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time);
static gboolean gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view,
static void
gtk_icon_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
VOID:OBJECT,INT
VOID:OBJECT,INT,OBJECT
VOID:OBJECT,INT,INT
-VOID:OBJECT,INT,INT,BOXED,UINT
VOID:OBJECT,OBJECT
VOID:OBJECT,POINTER
VOID:OBJECT,POINTER,INT
guint time);
static void gtk_notebook_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *data,
guint time);
static void gtk_notebook_direction_changed (GtkWidget *widget,
static void stop_scrolling (GtkNotebook *notebook);
static void do_detach_tab (GtkNotebook *from,
GtkNotebook *to,
- GtkWidget *child,
- gint x,
- gint y);
+ GtkWidget *child);
/* GtkBuildable */
static void gtk_notebook_buildable_init (GtkBuildableIface *iface);
priv->detached_tab->child, x, y, &dest_notebook);
if (dest_notebook)
- do_detach_tab (notebook, dest_notebook, priv->detached_tab->child, 0, 0);
+ do_detach_tab (notebook, dest_notebook, priv->detached_tab->child);
priv->rootwindow_drop = FALSE;
}
priv->detached_tab->child, x, y, &dest_notebook);
if (dest_notebook)
- do_detach_tab (notebook, dest_notebook, priv->detached_tab->child, 0, 0);
+ do_detach_tab (notebook, dest_notebook, priv->detached_tab->child);
return TRUE;
}
gint y,
guint time)
{
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GdkAtom target, tab_target;
target = gtk_drag_dest_find_target (widget, context, NULL);
if (target == tab_target)
{
+ notebook->priv->mouse_x = x;
+ notebook->priv->mouse_y = y;
gtk_drag_get_data (widget, context, target, time);
return TRUE;
}
}
static void
-do_detach_tab (GtkNotebook *from,
- GtkNotebook *to,
- GtkWidget *child,
- gint x,
- gint y)
+do_detach_tab (GtkNotebook *from,
+ GtkNotebook *to,
+ GtkWidget *child)
{
GtkNotebookPrivate *to_priv = to->priv;
GtkWidget *tab_label, *menu_label;
gtk_notebook_detach_tab (from, child);
- to_priv->mouse_x = x;
- to_priv->mouse_y = y;
-
element = get_drop_position (to);
page_num = g_list_position (to_priv->children, element);
gtk_notebook_insert_page_menu (to, child, tab_label, menu_label, page_num);
static void
gtk_notebook_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *data,
guint time)
{
{
child = (void*) gtk_selection_data_get_data (data);
- do_detach_tab (GTK_NOTEBOOK (source_widget), notebook, *child, x, y);
+ do_detach_tab (GTK_NOTEBOOK (source_widget), notebook, *child);
gtk_drag_finish (context, TRUE, FALSE, time);
}
else
* static void
* on_drag_data_received (GtkWidget *widget,
* GdkDragContext *context,
- * gint x,
- * gint y,
* GtkSelectionData *data,
* guint time,
* gpointer user_data)
guint time);
static void gtk_text_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time);
static void
gtk_text_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
guint time);
static void gtk_tree_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time);
static void
gtk_tree_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- /* coordinates relative to the widget */
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time)
{
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
NULL, NULL,
- _gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT,
- G_TYPE_NONE, 5,
+ _gtk_marshal_VOID__OBJECT_BOXED_UINT,
+ G_TYPE_NONE, 3,
GDK_TYPE_DRAG_CONTEXT,
- G_TYPE_INT,
- G_TYPE_INT,
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT);
guint time_);
void (* drag_data_received) (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint time_);
gboolean (* drag_failed) (GtkWidget *widget,
void
target_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
void
label_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
static void
image_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint32 time,
gpointer data)
static void
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
static void
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *selection_data,
guint32 time,
gpointer data)
static void
on_button_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x,
- gint y,
GtkSelectionData *data,
guint time,
gpointer user_data)
static void
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
- gint x, gint y,
GtkSelectionData *selda,
guint time,
gpointer dada)